﻿using System;
using System.Web;
using Framework;

namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 编辑产品分类
    /// </summary>
    public partial class EditProductCategory : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            object result;
            try
            {
                var file = Request.Files["Filedata"];
                var id = Fq("CoProductCategoryId").SafeToInt();
                var name = Fq("CoName");
                var sorts = Fq("CoSort").SafeToInt();
                var nameEn = Fq("CoNameEn");
                var productCategoryService = new ProductCategoryService();
                if (file != null)
                {
                    var filedata = new HttpPostedFileWrapper(Request.Files["Filedata"]);
                    productCategoryService.Edit(id, name, nameEn, sorts, filedata);
                }
                else
                {
                    productCategoryService.Edit(id, name, nameEn, sorts);
                }
                result = new { state = true, message = "修改成功" };
            }
            catch (Exception ex)
            {
                result = new { state = false, message = ex.Message };
            }
            Response.Write(result.Serialization());
            Response.End();

        }
    }
}